﻿using Thinker.SignChannel.Entities;
using Thinker.SignChannel.Records;
using IObjectMapper = Volo.Abp.ObjectMapping.IObjectMapper;

namespace Thinker.SignChannel.Dto;

public static class SignRecordDtoExtensions
{
    public static SignRecordDto ToSignRecordDto(this RecordInfo info, IObjectMapper objectMapper)
    {
        var dto = new SignRecordDto
        {
            RecordTime = info.Record.RecordTime,
            IdNumber = info.Record.IdNumber,
            PersonName = info.Record.PersonName
        };

        if (info.Person != null)
        {
            dto.Person = objectMapper.Map<Person, PersonCoreDto>(info.Person);
        }

        if (info.Time != null)
        {
            dto.Time = objectMapper.Map<Time, TimeCoreDto>(info.Time);
        }

        return dto;
    }
}